<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateArea extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('area', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('areaId')->comment('区域id')->default(0);
            $table->unsignedInteger('areaPid')->comment('区域父级id')->default(0);
            $table->string('cnShortName', 120)->comment('中文简写名称')->default('');
            $table->string('cnFullName', 120)->comment('中文全称')->default('');
            $table->unsignedTinyInteger('level')->comment('等级  1 - 省 2 - 市 3 - 区')->default(0);
            $table->string('adCode', 18)->comment('adCode')->default('');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");

            $table->index("areaPid", "idx_areaPid");
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '省市区域表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('area');
    }
}
